package utils.ioclasses;

import java.io.PrintWriter;
import java.io.StringWriter;

public class FileStringPrintWriter extends MultiPrintWriter {
    private final StringWriter stringWriter;

    public FileStringPrintWriter(PrintWriter printWriter, StringWriter stringWriter) {
        super(printWriter, new PrintWriter(stringWriter));
        this.stringWriter = stringWriter;
    }
    @Override
    public String toString() {
        return stringWriter.toString();
    }

    @Override
    public void close() {
        super.close();
        super.targetWriters.get(0).close();
        super.targetWriters.get(1).close();
    }
}
